﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;
using Omnia.Infrastructure;

namespace Omnia.DataModels
{
    public class PictureInfo:NotificationObject
    {
        public string FileName { get; set; }

        private Stream streamInfo;
        public Stream StreamInfo
        {
            get { return streamInfo; }
            set
            {
                streamInfo = value;
                RaisePropertyChanged(() => StreamInfo);
                RaisePropertyChanged(() => Buffer);
            }
        }
        public byte[] Buffer
        {
            get
            {

                using (MemoryStream ms = new MemoryStream())
                {
                    byte[] buffer = new byte[8 * 1024];
                    int read = 0;
                    while ((read = StreamInfo.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        ms.Write(buffer, 0, read);
                    }
                    return ms.ToArray();
                }
            }
        }
    }
}
